<?php
//用户
class memberMod extends base{
	
	//用户中心首页
	public function index(){
		$data['CardNo'] = $this->_G['member']['CardNo'];
		
		$client = post_curl($data, 'MEMBER_GET_INFO');	
		
		if($client['status']!=1){
			$this->error(lang::get($client['status']));
		}else{
			$member = $client['Msg'][0];
			$this->assign($member);			
			$this->display();	
		}
		
			
	}
	//资料
	public function ziliao(){
		$data['CardNo'] = $this->_G['member']['CardNo'];
		
		$client = post_curl($data, 'MEMBER_GET_INFO');	
			
		if($client['status']!=1){
			$this->error(lang::get($client['status']));
		}else{
			$member = $client['Msg'][0];
			//print_r($member);
			$this->assign($member);			
			$this->display();	
		}	
	}
	//资料修改
	public function edit(){
		if(cpHttpRequest::isPost()){
			$data = $_POST;			
			$client = post_curl($data, 'MEMBER_MODIFY');
			if($client['status']!=1){
				$this->error(lang::get($client['status']));
			}else{
				//更新用户资料session
				$client_member=post_curl(array('CardNo'=>$this->_G['member']['CardNo']), 'MEMBER_GET_INFO');
				if($client_member['status']!=1){
					$this->error(lang::get($client_member['status']));
				}else{
								
					$member = cp_encode($client_member['Msg'][0],cpConfig::get('authkey'));
					cookie('member', $member);			
				}	
				
				$this->success('资料修改成功');
				exit;
			}	
			
		}else{
			
			$data['CardNo'] = $this->_G['member']['CardNo'];
		
			$client = post_curl($data, 'MEMBER_GET_INFO');	
				
			if($client['status']!=1){
				$this->error(lang::get($client['status']));
			}else{
				$member = $client['Msg'][0];				
				$this->assign($member);			
				$this->display();	
			}		
		}		
		
	}
	//积分
	public function jifen(){			
		$this->display();		
	}
	//修改密码
	public function password(){
		
		if(cpHttpRequest::isPost()){
			if($_POST['NewPassWord']!=$_POST['NewPassWord2']){
				$this->error('重复密码错误');
			}
			//组合数据
			$data = $_POST;
			unset($data['NewPassWord2']);
			$data['CardNo'] = $this->_G['member']['CardNo'];
			//修改密码			
			$client = post_curl($data, 'MEMBER_CHANGE_PASSWORD');							
			if($client['status']!=1){
				//echo $client['status'];
				$this->error(lang::get($client['status']));
			}else{						
				$this->success('密码修改成功');
				exit;
			}		
			
		}else{
			$this->display();
		}		
				
	}
	
	
}
?>